<?php

namespace App;


use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Http\Request;

class User extends Authenticatable
{
    #主键
    protected $primaryKey='uid';
    
    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = [
        'uid','name', 'password', 'type',
    ];

    /**
     * The attributes excluded from the model's JSON form.
     *
     * @var array
     */
    protected $hidden = [
        'password', 'remember_token',
    ];


    public function projects(){
        return $this->hasMany('App\Models\Project_info','tid','uid');
    }


    public static function modify_info(Request $request){

        $user=User::find($_SESSION['sid']);
        $user->name=$request->name;
        $user->phone=$request->phone;
        $user->email=$request->email;

        try {
            $user->save();

        } catch (Exception $e) {
            return false;
        }
        
        return true;

    }


}
